package Dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class LoginDao {
    public static boolean checkUser(String username,String password) {
        Connection conn = DataBaseLink.getMysqlConn();
        String sql = "select * from user where username = ? and password = ?";

        PreparedStatement preparedStatement = null;
        try {
            preparedStatement = conn.prepareStatement(sql);
            preparedStatement.setString(1, username);
            preparedStatement.setString(2, password);
            ResultSet set = preparedStatement.executeQuery();
            if (set.next()) {
                return true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DataBaseLink.closeConnection(preparedStatement, conn);
        }


        return false;
    }
}
